package com.keiou.drink.widget;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.PopupWindow;

import com.keiou.drink.R;

/**
 * 作者 ：Bob on 2017/10/30.
 * 邮箱 ：motherlovefather@126.com
 */

public class RestorePopup extends PopupWindow {

    private View root;
    private ImageView ivCancel;
    private ImageView ivSure;
    private OnSelectClickImpl onSelectClickImpl;

    public RestorePopup(Context context) {
        setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        setHeight(ViewGroup.LayoutParams.MATCH_PARENT);

        root = LayoutInflater.from(context).inflate(R.layout.pop_restore, null);
        ivCancel = (ImageView) root.findViewById(R.id.iv_no);
        ivSure = (ImageView) root.findViewById(R.id.iv_yes);
        setContentView(root);
        setFocusable(true); // 设置PopupWindow可获得焦点
        setTouchable(true); // 设置PopupWindow可触摸
        setOutsideTouchable(false);
        setBackgroundDrawable(new ColorDrawable(Color.parseColor("#00000000")));

        ivCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != onSelectClickImpl) onSelectClickImpl.onNoClick();
            }
        });
        ivSure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (null != onSelectClickImpl) onSelectClickImpl.onYesClick();
            }
        });
    }

    public void setOnSelectClickImpl(OnSelectClickImpl onSelectClickImpl) {
        this.onSelectClickImpl = onSelectClickImpl;
    }

    public interface OnSelectClickImpl {
        void onNoClick();

        void onYesClick();
    }

    public void initView() {

    }
}
